// 外来组件加载控件变量
var arcGISObject = {hasInitFinsh:false, initFinshEvent:null};
var cesiumObject = {hasInitFinsh:false, initFinshEvent:null};
var echartsObject = {hasInitFinsh:false, initFinshEvent:[]};
var editObject = {hasInitFinsh:false, initFinshEvent:[]};

require.config({
    baseUrl: './',
    paths: {
        'jquery-easyui' : 'http://localhost/web-base/jquery-easyui/v1.5.2/jquery.easyui.min',
        'jquery-easyui-zh' : 'http://localhost/web-base/jquery-easyui/v1.5.2/locale/easyui-lang-zh_CN',

        'angular': 'http://localhost/web-base/angular/v1.3.0/angular.min',
        'angular-route': 'http://localhost/web-base/angular/v1.3.0/angular-route.min',
        'angular-ui-router': 'http://localhost/web-base/angular/v1.3.0/angular-ui-router.min',
        'angular-async-loader': 'http://localhost/web-base/angular-async-loader/angular-async-loader.min',

        'ui-datebox': 'http://localhost/angular-base/angular-ui/easyui/base/ui-datebox',
        'ui-hide-novalidate': 'http://localhost/angular-base/angular-ui/easyui/base/ui-hide-novalidate',
        'ui-include': 'http://localhost/angular-base/angular-ui/easyui/base/ui-include',
        'ui-tabs': 'http://localhost/angular-base/angular-ui/easyui/base/ui-tabs',
        'ui-textarea': 'http://localhost/angular-base/angular-ui/easyui/base/ui-textarea',
        'ui-window': 'http://localhost/angular-base/angular-ui/easyui/base/ui-window',
        'easyui-base': 'http://localhost/angular-base/angular-ui/easyui/base/easyui-base',

        'as-chinese-bool': 'http://localhost/angular-base/angular-ui/easyui/extend/as-chinese-bool',
        'as-chinese-date': 'http://localhost/angular-base/angular-ui/easyui/extend/as-chinese-date',
        'as-date': 'http://localhost/angular-base/angular-ui/easyui/extend/as-date',
        'as-empty': 'http://localhost/angular-base/angular-ui/easyui/extend/as-empty',
        'as-length': 'http://localhost/angular-base/angular-ui/easyui/extend/as-length',
        'easyui-extend': 'http://localhost/angular-base/angular-ui/easyui/extend/easyui-extend',

        'ui-combo': 'http://localhost/angular-base/angular-ui/easyui/form/ui-combo',
        'ui-combobox': 'http://localhost/angular-base/angular-ui/easyui/form/ui-combobox',
        'ui-combotree': 'http://localhost/angular-base/angular-ui/easyui/form/ui-combotree',
        'ui-date': 'http://localhost/angular-base/angular-ui/easyui/form/ui-date',
        'ui-dep': 'http://localhost/angular-base/angular-ui/easyui/form/ui-dep',
        'ui-page': 'http://localhost/angular-base/angular-ui/easyui/form/ui-page',
        'ui-tree': 'http://localhost/angular-base/angular-ui/easyui/form/ui-tree',
        'ui-user': 'http://localhost/angular-base/angular-ui/easyui/form/ui-user',
        'easyui-form': 'http://localhost/angular-base/angular-ui/easyui/form/easyui-form',

        //'easyui': 'http://localhost/angular-base/angular-ui/easyui/easyui',
         'easyui': 'http://localhost/angular-base/dest/ui/easyui',

        'data-simple': 'http://localhost/angular-base/angular-form/data/data-simple',

        'form-init': 'http://localhost/angular-base/angular-form/base/form-init',
        'form-search': 'http://localhost/angular-base/angular-form/base/form-search',
        'form-selected': 'http://localhost/angular-base/angular-form/base/form-selected',
        'form-delete': 'http://localhost/angular-base/angular-form/base/form-delete',
        'form-edit-simple': 'http://localhost/angular-base/angular-form/base/form-edit-simple',
        'form-tree-init': 'http://localhost/angular-base/angular-form/base/form-tree-init',
        'form-tree-search': 'http://localhost/angular-base/angular-form/base/form-tree-search',
        'form-tree-edit-simple': 'http://localhost/angular-base/angular-form/base/form-tree-edit-simple',

        'form-child-simple': 'http://localhost/angular-base/angular-form/child/form-child-simple',

        'dictionary': 'http://localhost/angular-base/angular-form/dictionary/dictionary',

        'router-ctrl': 'http://localhost/angular-base/angular-form/router-ctrl',
        //'form': 'http://localhost/angular-base/angular-form/form',
         'form': 'http://localhost/angular-base/dest/form/form',

        'security': 'http://localhost/angular-base/angular-security/security',
        // 'security': 'http://localhost/angular-base/dest/security/security.min',

        'arcgis-draw' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-draw',
        'arcgis-geoservice' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-geoservice',
        'arcgis-graphic' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-graphic',
        'arcgis-measure' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-measure',
        'arcgis-printing' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-printing',
        'arcgis-toolbar' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-toolbar',
        'arcgis-utils' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-utils',
        'arcgis-base' :'http://localhost/angular-base/angular-gis/arcgis3/base/arcgis-base',

        'arcgis-locator' :'http://localhost/angular-base/angular-gis/arcgis3/locator/arcgis-locator',

        'arcgis-map-base' :'http://localhost/angular-base/angular-gis/arcgis3/map/arcgis-map-base',
        'arcgis-map-layer' :'http://localhost/angular-base/angular-gis/arcgis3/map/arcgis-map-layer',
        'arcgis-map-ui' :'http://localhost/angular-base/angular-gis/arcgis3/map/arcgis-map-ui',
        'arcgis-map' :'http://localhost/angular-base/angular-gis/arcgis3/map/arcgis-map',

        'arcgis-search-attribute' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-attribute',
        'arcgis-search-find' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-find',
        'arcgis-search-identify' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-identify',
        'arcgis-search-result-mutli' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-result-mutli',
        'arcgis-search-result-simple' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-result-simple',
        'arcgis-search-space' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-space',
        'arcgis-search-utils' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search-utils',
        'arcgis-search' :'http://localhost/angular-base/angular-gis/arcgis3/search/arcgis-search',

        'arcgis-ui-page' :'http://localhost/angular-base/angular-gis/arcgis3/ui/arcgis-ui-page',
        'arcgis-ui' :'http://localhost/angular-base/angular-gis/arcgis3/ui/arcgis-ui',

        'arcgis' :'http://localhost/angular-base/angular-gis/arcgis3/arcgis',
        // 'arcgis3' :'http://localhost/angular-base/dest/gis/arcgis3.min',

        'cesium-draw' :'http://localhost/angular-base/angular-gis/cesium1/base/cesium-draw',
        'cesium-graphic' :'http://localhost/angular-base/angular-gis/cesium1/base/cesium-graphic',
        'cesium-toolbar' :'http://localhost/angular-base/angular-gis/cesium1/base/cesium-toolbar',
        'cesium-utils' :'http://localhost/angular-base/angular-gis/cesium1/base/cesium-utils',
        'cesium-base' :'http://localhost/angular-base/angular-gis/cesium1/base/cesium-base',

        'cesium-locator' :'http://localhost/angular-base/angular-gis/cesium1/locator/cesium-locator',

        'cesium-map-base' :'http://localhost/angular-base/angular-gis/cesium1/map/cesium-map-base',
        'cesium-map-layer' :'http://localhost/angular-base/angular-gis/cesium1/map/cesium-map-layer',
        'cesium-map-ui' :'http://localhost/angular-base/angular-gis/cesium1/map/cesium-map-ui',
        'cesium-map' :'http://localhost/angular-base/angular-gis/cesium1/map/cesium-map',

        'cesium':'http://localhost/angular-base/angular-gis/cesium1/cesium',
        // 'cesium1':'http://localhost/angular-base/dest/gis/cesium1.min',

        'gis-toolbar' :'http://localhost/angular-base/angular-gis/gis/base/toolbar',
        'gis-locator' :'http://localhost/angular-base/angular-gis/gis/locator/locator',
        'gis-config' :'http://localhost/angular-base/angular-gis/gis/config',
        'gis' :'http://localhost/angular-base/angular-gis/gis/gis',
        'arcgis_analysis':'http://localhost/angular-base/angular-gis/arcgis3/analysis/arcgis-analysis-base',
        // 'gis' :'http://localhost/angular-base/dest/gis/gis.min',

        'app' : 'app',
        'app-routes': 'app-routes',

        'cesiumjs' : 'http://localhost/web-base/cesiumjs/v1.38/Cesium',
        
        'echarts':'http://localhost/web-base/echarts/echarts.min',
        'echarts-pie':'http://localhost/angular-base/angular-echarts/echarts-pie',
        'echarts.china':'http://localhost/web-base/echarts/china.map',
        'ui.echarts':'http://localhost/angular-base/angular-ui/extend/charts/ui-echarts',

        'plupload':'http://localhost/web-base/plupload/v2.1.4/plupload.full.min',
        'plupload.queue':'http://localhost/web-base/plupload/v2.1.4/jquery.plupload.queue/jquery.plupload.queue.min',
        'plupload.i18n':'http://localhost/web-base/plupload/v2.1.4/i18n/zh_CN',

        'as-files' : 'http://localhost/angular-base/angular-ui/extend/upload/as-files',
        'ui-upload' : 'http://localhost/angular-base/angular-ui/extend/upload/ui-upload',

        'kindeditor':'http://localhost/web-base/kindeditor/v4.1.11/kindeditor-all',
        'kindeditor.i18n':'http://localhost/web-base/kindeditor/v4.1.11/zh-CN',
        'ui-edit':'http://localhost/angular-base/angular-ui/extend/edit/ui-edit',
        'bpm-init':'http://localhost/angular-base/angular-activiti/base/bpm-init',
        'bpm-workflow':'http://localhost/angular-base/angular-activiti/base/bpm-workflow',
        'bpm-workflow-sign':'http://localhost/angular-base/angular-activiti/base/bpm-workflow-sign',
        'bpm-workflow-back':'http://localhost/angular-base/angular-activiti/base/bpm-workflow-back',
        'bpm-workflow-skip':'http://localhost/angular-base/angular-activiti/base/bpm-workflow-skip',
        'bpm-workflow-disposal':'http://localhost/angular-base/angular-activiti/base/bpm-workflow-disposal',
        'bpm-selected' :'http://localhost/angular-base/angular-activiti/base/bpm-selected',
        'bpm-process' :'http://localhost/angular-base/angular-activiti/base/bpm-process'
    },
    packages: [
        { name: 'bmap', location: "http://localhost/web-base/arcgis/extent/bmap" },
        { name: 'tdmap', location: "http://localhost/web-base/arcgis/extent/tdmap" },
        { name: 'dijit', location: "http://localhost/web-base/arcgis/v3.21/dijit" },
        { name: 'dojo', location: "http://localhost/web-base/arcgis/v3.21/dojo" },
        { name: 'dojox', location: "http://localhost/web-base/arcgis/v3.21/dojox" },
        { name: 'esri', location: "http://localhost/web-base/arcgis/v3.21/esri" },
        { name: 'moment', location: "http://localhost/web-base/arcgis/v3.21/moment" }
    ],
    shim: {
        'angular': {exports: 'angular'},
    	'angular-route': {deps: ['angular']},
        'angular-ui-router': {deps: ['angular']},
        'angular-async-loader': {deps: ['angular']},

        'ui-datebox': {deps: ['angular']},
        'ui-hide-novalidate': {deps: ['angular']},
        'ui-include': {deps: ['angular']},
        'ui-tabs': {deps: ['angular']},
        'ui-textarea': {deps: ['angular']},
        'ui-window': {deps: ['angular']},
        'easyui-base':{deps: ['angular']},

        'as-chinese-bool': {deps: ['angular']},
        'as-chinese-date': {deps: ['angular']},
        'as-date': {deps: ['angular']},
        'as-empty' : {deps: ['angular']},
        'as-length': {deps: ['angular']},
        'easyui-extend':{deps: ['angular']},
        
        'ui-combo': {deps: ['angular']},
        'ui-combobox': {deps: ['angular']},
        'ui-combotree': {deps: ['angular']},
        'ui-date': {deps: ['angular']},
        'ui-dep': {deps: ['angular']},
        'ui-page': {deps: ['angular']},
        'ui-tree': {deps: ['angular']},
        'ui-user': {deps: ['angular']},
        'easyui-form':{deps: ['angular']},
        
        'easyui': {deps: ['angular']},
        // 'easyui': {deps: ['angular']},

        'data-simple': {deps: ['angular']},
        'form-init': {deps: ['angular']},
        'form-search': {deps: ['angular']},
        'form-selected': {deps: ['angular']},
        'form-delete': {deps: ['angular']},
        'form-edit-simple': {deps: ['angular']},
        'form-tree-init': {deps: ['angular']},
        'form-tree-search': {deps: ['angular']},
        'form-tree-edit-simple': {deps: ['angular']},

        'form-child-simple':{deps: ['angular']},

        'dictionary':{deps: ['angular']},
        
        'router-ctrl': {deps: ['angular']},
        'form': {deps: ['angular']},
        // 'form': {deps: ['angular']},

        'security' : {deps: ['angular']},

        'arcgis-draw' :{deps: ['angular']},
        'arcgis-geoservice' :{deps: ['angular']},
        'arcgis-graphic' :{deps: ['angular']},
        'arcgis-measure' :{deps: ['angular']},
        'arcgis-printing' :{deps: ['angular']},
        'arcgis-toolbar' :{deps: ['angular']},
        'arcgis-utils' :{deps: ['angular']},
        'arcgis-base' :{deps: ['angular']},

        'arcgis-locator' :{deps: ['angular']},

        'arcgis-map-base' :{deps: ['angular']},
        'arcgis-map-layer' :{deps: ['angular']},
        'arcgis-map-ui' :{deps: ['angular']},
        'arcgis-map' :{deps: ['angular']},

        'arcgis-search-attribute' :{deps: ['angular']},
        'arcgis-search-find' :{deps: ['angular']},
        'arcgis-search-identify' :{deps: ['angular']},
        'arcgis-search-result-mutli' :{deps: ['angular']},
        'arcgis-search-result-simple' :{deps: ['angular']},
        'arcgis-search-space' :{deps: ['angular']},
        'arcgis-search-utils' :{deps: ['angular']},
        'arcgis-search' :{deps: ['angular']},

        'arcgis-ui-page' :{deps: ['angular']},
        'arcgis-ui' :{deps: ['angular']},

        'arcgis' :{deps: ['angular']},
        // 'arcgis3' :{deps: ['angular']},

        'cesium-draw' :{deps: ['angular']},
        'cesium-graphic' :{deps: ['angular']},
        'cesium-toolbar' :{deps: ['angular']},
        'cesium-utils' :{deps: ['angular']},
        'cesium-base' :{deps: ['angular']},

        'cesium-locator' :{deps: ['angular']},

        'cesium-map-base' :{deps: ['angular']},
        'cesium-map-layer' :{deps: ['angular']},
        'cesium-map-ui' :{deps: ['angular']},
        'cesium-map' :{deps: ['angular']},
        'cesium':{deps: ['angular']},
        // 'cesium1':{deps: ['angular']},

        'gis-toolbar' :{deps: ['angular']},
        'gis-locator' :{deps: ['angular']},
        'gis-config' :{deps: ['angular']},
        'gis' :{deps: ['angular']},
        'arcgis_analysis' :{deps: ['angular']},
        // 'gis' :{deps: ['angular']},
        
        'app-routes' : {deps: ['angular']},

        'kindeditor.i18n':{deps: ['kindeditor']},
        'ui-edit':{deps: ['angular']},

        'plupload':{exports: 'plupload'},
        'plupload.queue':{deps: ['plupload']},
        'plupload.i18n':{deps: ['plupload']},
        'as-files' :{deps: ['angular']},
        'ui-upload' :{deps: ['angular']},
        'bpm-workflow' :{deps: ['angular']},
        'bpm-workflow-sign' :{deps: ['angular']},
        'bpm-workflow-back' :{deps: ['angular']},
        'bpm-workflow-skip' :{deps: ['angular']},
        'bpm-workflow-disposal' :{deps: ['angular']},
        
        'bpm-init' :{deps: ['angular']},
        'bpm-selected' :{deps: ['angular']},
        'bpm-process' :{deps: ['angular']},
    }
});

// angular app 加载
require(['angular','app','app-routes'], function (angular) {
    angular.element(document).ready(function () {
        angular.bootstrap(document, ['app']);
        angular.element(document).find('html').addClass('ng-app');
    });
});

// arcgis 2d 地图加载
require([
    'bmap/bMapVeclayer',
    'bmap/bMapImglayer',
    'bmap/bMapAnolayer',

    'tdmap/tdMapAnnoLayer',
    'tdmap/tdMapLayer',
    'tdmap/tdMapImgAnnoLayer',
    'tdmap/tdMapImgLayer',

    'dojo/parser',
    'dojo/domReady!',

    'esri/map',
    'esri/layers/WMSLayer',
    'esri/layers/WMTSLayer', 
    'esri/layers/WMTSLayerInfo',
    'esri/layers/ImageParameters',
    'esri/layers/ArcGISImageServiceLayer', 
    'esri/layers/ImageServiceParameters',
    'esri/layers/GraphicsLayer',
    'esri/layers/ArcGISDynamicMapServiceLayer',

    'esri/tasks/locator',
    'esri/tasks/geometry',
    'esri/tasks/query',
    'esri/tasks/PrintTask',
    'esri/tasks/PrintTemplate',
    'esri/tasks/PrintParameters',
    'esri/tasks/IdentifyTask',
    'esri/tasks/IdentifyParameters',
    'esri/tasks/FindTask',
    'esri/tasks/FindParameters',

    'esri/graphic',
    'esri/geometry/Point',
    'esri/geometry/Polygon',
    'esri/geometry/Extent',
    'esri/SpatialReference',
    'esri/toolbars/navigation',
    'esri/toolbars/draw',

    "esri/dijit/Scalebar",
    
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleFillSymbol'
    ], function (bMapVeclayer,bMapImglayer,bMapAnolayer,
        tdMapAnnoLayer,tdMapLayer,tdMapImgAnnoLayer,tdMapImgLayer) { 
        arcGISObject.hasInitFinsh=true;
        if(arcGISObject.initFinshEvent){
            arcGISObject.initFinshEvent();
        }
        
        arcGISObject.bmapVeclayer = new bMapVeclayer();
        arcGISObject.bmapImglayer = new bMapImglayer();
        arcGISObject.bmapAnolayer = new bMapAnolayer();

        arcGISObject.tdmapAnnoLayer = new tdMapAnnoLayer();
        arcGISObject.tdmapLayer = new tdMapLayer();
        arcGISObject.tdmapImgAnnoLayer = new tdMapImgAnnoLayer();
        arcGISObject.tdmapImgLayer = new tdMapImgLayer();
    }
);

// 3d 地图加载
require(['cesiumjs'], function () {
    cesiumObject.hasInitFinsh=true;
    if(cesiumObject.initFinshEvent){
        cesiumObject.initFinshEvent();
    }
});